package loggers;

import connections.Uploader;

public class LogWristbandData extends LogDataFromBTConnection{
	
	

	public byte[] formatSensorData(byte[] input){
	
		short accX; /* Accelerometer x */
		short accY;
		short accZ;
		short magX; /* Magnetometer x */
		short magY;
		short magZ;
		short gyrX; /* Gyroscope x */
		short gyrY;
		short gyrZ;
		String s = "Record:";
		if (input.length > 27) {


			String timeStamp = String.valueOf(System.currentTimeMillis());
			s = s +   timeStamp + "," + (input[2] & 0x00FF) + "," ;

			accX = (short) ((((short) input[10]) & 0x00FF) + (((short) input[9]) * 255) - 32512);
			accY = (short) ((((short) input[12]) & 0x00FF) + (((short) input[11]) * 255) - 32512);
			accZ = (short) ((((short) input[14]) & 0x00FF) + (((short) input[13]) * 255) - 32512);
			s = s  + accX + ","+ accY + ","+  accZ + ",";

			magX = (short) ((((short) input[16]) & 0x00FF) + (((short) input[15]) * 255) - 32512);
			magY = (short) ((((short) input[18]) & 0x00FF) + (((short) input[17]) * 255) - 32512);
			magZ = (short) ((((short) input[20]) & 0x00FF) + (((short) input[19]) * 255) - 32512);
			s = s  + magX +  magY + ","+  magZ + ",";
			gyrX = (short) ((((short) input[22]) & 0x00FF) + (((short) input[21]) * 255) - 32512);
			gyrY = (short) ((((short) input[24]) & 0x00FF) + (((short) input[23]) * 255) - 32512);
			gyrZ = (short) ((((short) input[26]) & 0x00FF) + (((short) input[25]) * 255) - 32512);
			s = s  +  gyrX + "," + gyrY + "," + gyrZ + "\r";
			//mainForm.append(s);
			System.out.println(s);
		}
		
		//return new byte[] {65,66,67};
		return s.getBytes();
	}

}
